<script lang="ts">
export default {
  name: "timeSet"
}
</script>

<script setup lang="ts">
import {reactive, ref, onMounted, toRefs} from 'vue'
import {timeAllocation} from '@/api/engineer/index'
import {Message} from "@element-plus/icons-vue";
import {ElMessage} from "element-plus";




const state = reactive({

})


const startTime = ref('')
const endTime = ref('')
const value1 = ref([])


const options = [
  {
    value: 'MONDAY',
    label: '周一',
  },
  {
    value: 'TUESDAY',
    label: '周二',
  },
  {
    value: 'WEDNESDAY',
    label: '周三',
  },
  {
    value: 'THURSDAY',
    label: '周四',
  },
  {
    value: 'FRIDAY',
    label: '周五',
  },
  {
    value: 'SATURDAY',
    label: '周六',
  },
  {
    value: 'SUNDAY',
    label: '周日',
  }
]

async function submit() {
  if(value1.value.length < 1) {
    ElMessage.error("请选择星期")
    return
  }

  if(!startTime.value) {
    ElMessage.error("请选择开始时间")
    return;
  }
  if(!endTime.value) {
    ElMessage.error("请选择结束时间")
    return;
  }
  let list1 = startTime.value.split(':')
  let list2 = endTime.value.split(':')
  let data = {
    week: value1.value,
    hour:[list1[0], list2[0]],
    minute:[list1[1], list2[1]]
  }
  let res:any = await timeAllocation(data)
  if (res.code == '00000') {
    ElMessage.success("修改成功")
  } else {
    ElMessage.error(res.data)
  }
}



onMounted(() => {

});

</script>

<template>
  <div class="app-container">

    <div style="display: flex">
      提现时间为工作日每
      <div>
        <el-select
          v-model="value1"
          multiple
          placeholder="请选择星期"
          style="width: 240px"
        >
          <el-option
            v-for="item in options"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
      </div>
      <div>
        <el-time-select
          v-model="startTime"
          style="width: 240px"
          :max-time="endTime"
          class="mr-4"
          placeholder="开始时间"
          start="00:00"
          step="00:15"
          end="24:00"
        />
        -
        <el-time-select
          v-model="endTime"
          style="width: 240px"
          :min-time="startTime"
          placeholder="结束时间"
          start="00:00"
          step="00:15"
          end="24:00"
        />
      </div>
      ，如遇法定节假日，则依次顺延至次周
    </div>
  </div>
  <div style="margin-left: 20px">
    <el-button type="primary" @click="submit">确定修改</el-button>
  </div>

</template>

<style scoped>

</style>